<?php include '../../common/view/header.html.php';?>
<div id='mainContent' class='main-row'>
  <div class='side-col col-lg'>
    <?php include 'blockreportlist.html.php';?>
    <div class='panel panel-body' style='padding: 10px 6px'>
      <div class='text proversion'>
        <strong class='text-danger small text-latin'>PRO</strong> &nbsp;<span class='text-important'><?php echo $lang->report->proVersion;?></span>
      </div>
    </div>
  </div>
  <div class='main-col'>
    <div class='cell'>
      <div class='with-padding'>
        <div class="table-row" id='conditions'>
          <div class="col-xs text-right side-col text-gray"><?php echo $lang->report->conditions?></div>
          <div class='col'>
            <div class="checkbox-primary inline-block">
              <input type="checkbox" name="closedProduct" value="closedProduct" id="closedProduct" <?php if(strpos($conditions, 'closedProduct') !== false) echo "checked='checked'"?> />
              <label for="closedProduct"><?php echo $lang->report->closedProduct?></label>
            </div>
            <div class="checkbox-primary inline-block">
              <input type="checkbox" name="overduePlan" value="overduePlan" id="overduePlan" <?php if(strpos($conditions, 'overduePlan') !== false) echo "checked='checked'"?> />
              <label for="overduePlan"><?php echo $lang->report->overduePlan?></label>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class='cell'>
      <div class='panel'>
        <div class="panel-heading">
          <div class="panel-title"><?php echo $title;?></div>
          <nav class="panel-actions btn-toolbar"></nav>
        </div>
        <table class='table table-condensed table-striped table-bordered table-fixed' id='productList'>
          <thead>
            <tr class='colhead'>
              <th width='200'><?php echo $lang->product->name;?></th>
              <th width='120'><?php echo $lang->product->PO;?></th>
              <th><?php echo $lang->productplan->common;?></th>
              <th width="100"><?php echo $lang->productplan->begin;?></th>
              <th width="100"><?php echo $lang->productplan->end;?></th>
              <th class="w-70px"><?php echo $lang->story->statusList['draft'];?></th>
              <th class="w-70px"><?php echo $lang->story->statusList['active'];?></th>
              <th class="w-70px"><?php echo $lang->story->statusList['changed'];?></th>
              <th class="w-70px"><?php echo $lang->story->statusList['closed'];?></th>
              <th class="w-70px"><?php echo $lang->report->total;?></th>
            </tr>
          </thead>
          <tbody>
            <?php $color = false;?>
            <?php foreach($products as $product):?>
            <tr class="text-center">
              <?php $count = isset($product->plans) ? count($product->plans) : 1;?>
              <td class='text-left' rowspan="<?php echo $count;?>"><?php echo "<p>" . html::a($this->createLink('product', 'view', "product=$product->id"), $product->name) . "</p>";?></td>
              <td class='text-left' rowspan="<?php echo $count;?>"><?php echo "<p>" . zget($users, $product->PO) . '</p>';?></td>
              <?php if(isset($product->plans)):?>
              <?php $id = 1;?>
              <?php foreach($product->plans as $plan):?>
                <?php $class = $color ? 'rowcolor' : '';?>
                <?php if($id != 1) echo "<tr class='text-center'>"?>
                  <td align='left' class="<?php echo $class;?>"><?php echo $plan->title;?></td>
                  <td class="<?php echo $class;?>"><?php echo $plan->begin == '2030-01-01' ? $lang->productplan->future : $plan->begin;?></td>
                  <td class="<?php echo $class;?>"><?php echo $plan->end == '2030-01-01' ? $lang->productplan->future : $plan->end;?></td>
                  <?php
                  $draftCount   = isset($plan->status['draft'])   ? $plan->status['draft']   : 0;
                  $activeCount  = isset($plan->status['active'])  ? $plan->status['active']  : 0;
                  $changedCount = isset($plan->status['changed']) ? $plan->status['changed'] : 0;
                  $closedCount  = isset($plan->status['closed'])  ? $plan->status['closed']  : 0;
                  ?>
                  <td class="<?php echo $class;?>"><?php echo $draftCount;?></td>
                  <td class="<?php echo $class;?>"><?php echo $activeCount;?></td>
                  <td class="<?php echo $class;?>"><?php echo $changedCount;?></td>
                  <td class="<?php echo $class;?>"><?php echo $closedCount;?></td>
                  <td class="<?php echo $class;?>"><?php echo $draftCount + $activeCount + $changedCount + $closedCount;?></td>
                <?php if($id != 1) echo "</tr>"?>
                <?php $id ++;?>
                <?php $color = !$color;?>
              <?php endforeach;?>
              <?php else:?>
                <?php $class = $color ? 'rowcolor' : '';?>
                <td class="<?php echo $class;?>"></td>
                <td class="<?php echo $class;?>"></td>
                <td class="<?php echo $class;?>"></td>
                <td class="<?php echo $class;?>"></td>
                <td class="<?php echo $class;?>"></td>
                <td class="<?php echo $class;?>"></td>
                <td class="<?php echo $class;?>"></td>
                <td class="<?php echo $class;?>"></td>
                <?php $color = !$color;?>
              <?php endif;?>
            </tr>
            <?php endforeach;?>
          </tbody>
        </table> 
      </div>
    </div>
  </div>
</div>
<?php include '../../common/view/footer.html.php';?>
